﻿@{
    ViewBag.Title = "数据恢复";
}
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head> 
 @if (false)
 {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
 }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(
                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

    )
    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)
    <script type="text/javascript">
        $(document).ready(function () {
            lpModal.Hide();
            var hdjsAlert = $("#hdjsAlert").val();
            var hidtype = $("#hidtype").val();
            var hidperiod = $("#hidFPeriod").val();
            var hidyear = $("#hidFYear").val();
            if (hdjsAlert != "") {
                if (hidtype == "N") {
                    if (hdjsAlert == "操作成功") {
                        alert(hdjsAlert);
                        parent.codeOK(hidperiod, hidyear);
                    }
                    else {
                        alert(hdjsAlert);
                    }
                }
                else {
                    if (hdjsAlert == "入库时间不可为空请修改后重新导入") {
                        alert(hdjsAlert);
                    }
                    else {
                        if (confirm(hdjsAlert)) {
                            lpModal.Show();
                            form1.submit();
                        }
                    }
                }
            }
        });

        function OnBeginCallback() {

        }
        function codeEdit(NSRSBH, NSRMC) {
            $("#popContent").attr("src", encodeURI(rootPath + "/GSImportDate/GompareImportDateEdit?nsrsbh=" + NSRSBH + "&bsrmc=" + NSRMC));
            codeModalMode.Show();
        }

        function codeOK() {
            codeModalMode.Hide();
            gvEditing.Refresh();
        }

        function codeCancel() {
            codeModalMode.Hide();
        }
        function OK() {
            lpModal.Show();
            if (upload.GetText() == "") {
                alert("请选择要上传的文件！");
                lpModal.Hide();
            } else {
                var fYear = FYear.GetText();
                var fPeriod = FPeriod.GetText();
                var beginDate = BeginDate.GetDate();
                var endDate = EndDate.GetDate();
                if (pd(fYear, fPeriod, beginDate, endDate)) {

                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/GSImportDate/ExistsGSData',
                        data: { fYear: fYear, fPeriod: fPeriod },
                        success: function (result) {
                            if (result == "Y") {
                                alert("该期数据已存在，请确定后继续操作！");
                                lpModal.Hide();
                            }
                            else {
                                form1.submit();
                            }
                        }
                    });

                }
                else {
                    lpModal.Hide();
                }
            }
        }

        function pd(fYear, fPeriod, beginDate, endDate) {
            var bl = true;
            if (null == fYear || ASPxClientUtils.Trim(fYear) == "") {
                FYear.SetErrorText("请填写年度！");
                FYear.SetIsValid(false);
                bl = false;
            }
            if (null == fPeriod || ASPxClientUtils.Trim(fPeriod) == "") {
                FPeriod.SetErrorText("请填写编号！");
                FPeriod.SetIsValid(false);
                bl = false;
            }
            if (null == beginDate || ASPxClientUtils.Trim(beginDate) == "") {
                BeginDate.SetErrorText("请填写完整所属年月！");
                BeginDate.SetIsValid(false);
                bl = false;
            }
            if (null == endDate || ASPxClientUtils.Trim(endDate) == "") {
                EndDate.SetErrorText("请填写完整所属年月！");
                EndDate.SetIsValid(false);
                bl = false;
            }

            return bl;
        }

    </script>



</head>
<body>
    @using (Html.BeginForm("GSImportDate", "GSImportDate", FormMethod.Post, new { id = "form1" }))
    {
        <div class="div">
        <table width="99%" align="center">
            <tr>
                <td align="right" width="20%">
                    上一批次:</td>
                <td class="tdClass">
               
                   @Html.DevExpress().TextBox(settings =>
              {
                  settings.Name = "DQPC";
                  settings.Width = 300;
                  settings.Text = ViewData["DQPC"].ToString();
                  settings.Enabled = false;

                  settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                  settings.Properties.ValidationSettings.EnableCustomValidation = true;
              }).GetHtml()
                </td>
            </tr>
             <tr>
            <td align="right" style=" width:150" class="tdClass">
               年度:</td>
            <td class="tdClass">
                @Html.DevExpress().TextBox(settings =>
           {
               settings.Name = "FYear";
               settings.Width = 300;
               settings.Text = EnterpriseFund.Common.OperateSession.get(EnterpriseFund.Common.GlobalConstant.PARAM_SYSYEAR);
               settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
               settings.Properties.ValidationSettings.EnableCustomValidation = true;
           }).GetHtml()
            </td>
        </tr>
        <tr>
            <td align="right" style=" width:150" class="tdClass">
                批次:</td>
            <td class="tdClass">
                @Html.DevExpress().TextBox(settings =>
           {
               settings.Name = "FPeriod";
               settings.Width = 300;
               settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
               settings.Properties.ValidationSettings.EnableCustomValidation = true;
           }).GetHtml()
            </td>
        </tr>
            <tr>
                <td align="right" width="20%" class="tdClass">
                    所属年月:</td>
                <td class="tdClass">
                <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                <td>
                @Html.DevExpress().DateEdit(settings =>
           {
               settings.Name = "BeginDate";
               settings.Properties.ShowShadow = true;
               settings.Properties.EditFormat = EditFormat.Date;
               settings.Properties.EditFormatString = "yyyy-MM";
               settings.Width = 145;
               settings.Date = DateTime.Now;
               settings.Properties.UseMaskBehavior = true;
           }).GetHtml()
                </td>
                
                    <td style=" width:10px; text-align:center">     -
                </td>
                    <td>
                                    @Html.DevExpress().DateEdit(settings =>
                               {
                                   settings.Name = "EndDate";
                                   settings.Properties.ShowShadow = true;
                                   settings.Properties.EditFormat = EditFormat.Date;
                                   settings.Width = 145;
                                   settings.Properties.EditFormatString = "yyyy-MM";
                                   settings.Date = DateTime.Now;
                                   settings.Properties.UseMaskBehavior = true;
                               }).GetHtml()
                </td>
                </tr>
                </table>
               </td>
            </tr>

            <tr>
                <td  align="right" width="20%" class="tdClass">
                选择操作:
                </td>
                
                <td class="tbClass" valign="middle">

                     @Html.DevExpress().UploadControl(
                        settings =>
                        {
                            settings.Name = "upload";
                            settings.BrowseButton.Text = "浏览";
                            settings.Height = System.Web.UI.WebControls.Unit.Percentage(100);
                            settings.Width = 300;
                            settings.ClearFileSelectionImage.ToolTip = "清除选择";
                            settings.ShowProgressPanel = true;
                            settings.ValidationSettings.MaxFileSize = 20971520;
                            settings.ShowUploadButton = false;
                            settings.ControlStyle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
                        }).GetHtml()
        
                </td>
            </tr>

            
           @* <tr>
                <th>
                </th>
                <th class="tbClass">
                     @Html.DevExpress().CheckBox(
                        settings =>
                        {
                            settings.Name = "delDate";
                            settings.Height = System.Web.UI.WebControls.Unit.Percentage(100);
                            settings.Text = "删除原有数据";
                            settings.Checked = true;
                        }).GetHtml()
                </th>
            </tr>*@

           @* <tr>
                <th></th>
                <th class="tbClass">

                @Html.DevExpress().Button(settings =>
           {
               settings.Name = "btnOK";
               settings.Text = "确定导入";
               settings.ControlStyle.CssClass = "button";
               settings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
               settings.ClientSideEvents.Click = "ok";
           }).GetHtml()
            </th>
            </tr>*@
            
        </table>
        @Html.Partial("GompareImportDateListPartial", ViewData["data"] as System.Data.DataTable)

         @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "codeModalMode";
        settings.Width = 400;
        settings.Height = 150;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent.OK()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "codeCancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
       {
           ViewContext.Writer.Write("<iframe  id='popContent' name='popContent' style='width:100%;height:150px; vertical-align: middle' frameborder='0' ></iframe>");
       });
    }).GetHtml()
    </div>
         @Html.Hidden("hidMessage", ViewData["message"])
         @Html.Hidden("hidIsClose", ViewData["IsClose"])
         @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]));
         @Html.Hidden("hidUrl", (ViewData["Url"]));   
         @Html.Hidden("hidBeginDate", (ViewData["beginDate"]));                                                                             
         @Html.Hidden("hidEndDate", ViewData["endDate"])
         @Html.Hidden("hidFYear", ViewData["fYear"])
         @Html.Hidden("hidFPeriod", (ViewData["fPeriod"]));
         @Html.Hidden("hidtype", (ViewData["type"]));     
         @Html.Hidden("hidsvrFileName", (ViewData["svrFileName"]));         
                                                                                                   
                                                 
    }
    <script>
        lp.Hide();
    </script>

</body>
</html>
